{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "978631f1",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "from qiskit import QuantumCircuit\n",
    "from qiskit_ibm_runtime import QiskitRuntimeService, Sampler, Estimator, Session\n",
    "\n",
    "service = QiskitRuntimeService()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c1e4a5f6",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdIAAADuCAYAAACNr4ZUAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAmu0lEQVR4nO3de3xNZ9738c9ORLackARJE4RIiNShlLkdWmUwzumJak31YEqno2OMx+HuuEfb20udxvSAlsetp0cNN6ZVVKtVLaZ1nGhLtEKQRIKIkAORw37+yCQjTSLZe+29VxLf9+uVV7L3Wtdavx2yv/ta61rXsthsNhsiIiLiEA+zCxAREanLFKQiIiIGKEhFREQMUJCKiIgYoCAVERExQEEqIiJigIJURETEAAWpiIiIAQpSERERAxSkIiIiBihIRUREDFCQioiIGKAgFRERMUBBKiIiYoCCVERExAAFqYiIiAEKUhEREQMUpCIiIgYoSEVERAxQkIqIiBigIBURETFAQSoiImKAglRERMQABamIiIgBClIREREDFKQiIiIGKEhFREQMaGB2ASJStx0/ftyu9S9cuMD69esZM2YMzZs3r1GbDh06OFKaiFuoRyoibnXx4kWWLVvGxYsXzS5FxCkUpCIiIgYoSEVERAxQkIqIiBigIBURt2rcuDEjR46kcePGZpci4hQWm81mM7sIEam77B216wiN2pXaTD1SEXGr/Px8zpw5Q35+vtmliDiFglRE3CoxMZEhQ4aQmJhodikiTqEgFRERMUAzG0mlbDa4UWR2FfZp6AkWi9lVS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pCTatWvHlClT+Oqrr4iOji5r4+/vz549e3j66adp2rQpP/74Izk5OUyaNInDhw8TFhZWYT/R0dGsWrWKRx55hNDQUE6dOsWRI0ewWq2MHj2a3bt3uyVEAa7n36DVHc3VGxURqYF60yMV57uefwOrd0OzyxARqdUUpCIiIgbo0K6IiIgBClIREREDFKQiIiIGKEhFREQMUJCKiIgYoCAVERExQEEqIiJigIJURETEAAWpiIiIAQpSERERAxSkIiIiBihIRUREDFCQioiIGKAgFRERMUBBKiIiYoCCVERExAAFqYiIiAEKUhEREQMUpCIiIgYoSEVERAxQkIqIiBigIBURETFAQSoiImKAglRERMQABamIiIgBClIREREDFKQiIiIGKEhFREQMUJCKiIgYoCAVERExQEEqIiJigIJURETEAAWpiIiIAQpSERERAxSkIiIiBihIRUREDFCQioiIGKAgFRERMUBBKiIiYsD/Byk6/HqoTJpWAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 580.387x284.278 with 1 Axes>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qc = QuantumCircuit(2)\n",
    "qc.h(0)\n",
    "qc.cx(0, 1)\n",
    "qc.measure_all()\n",
    "\n",
    "qc.draw('mpl')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "572c2938",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "backend = service.get_backend('ibm_lagos')\n",
    "\n",
    "with Session(service=service, backend=backend) as session:\n",
    "    sampler = Sampler()\n",
    "    job = sampler.run(circuits=qc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "96a6dea6",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "plt.style.use('dark_background')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e4d0c4bc",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "job.result()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "69694587",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "from qiskit.visualization import plot_histogram\n",
    "\n",
    "plot_histogram(job.result().quasi_dists[0].binary_probabilities())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4ed7608f",
   "metadata": {
    "scrolled": true,
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "job.inputs['circuits'][0].draw('mpl')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "62e912f4",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [],
   "source": [
    "print(job.logs())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "28f3ffaf",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "from friends import retrieve_observable_and_ansatz\n",
    "obsv, qc, params = retrieve_observable_and_ansatz()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24cbb3e5",
   "metadata": {
    "scrolled": true,
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "obsv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "95cf2089",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [],
   "source": [
    "qc.draw('mpl', fold=-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "95c1891a",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [],
   "source": [
    "params"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f0419f7a",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "with Session(service=service, backend=backend) as session:\n",
    "    estimator = Estimator()\n",
    "    job = estimator.run(circuits=qc, observables=obsv, parameter_values=params)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1f7373c6",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "job.result()"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "qiskit-stable",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  },
  "rise": {
   "theme": "monokai",
   "transition": "none"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
